import numpy as np

print("------0----")

t1 = np.arange(12)
print("t1: ", t1)
print("t1:.shape：", t1.shape)  # 查看数组的形状  t1:.shape： (12,)

print("------1----")

t2 = np.array([[1,2,3], [4,5,6]])
print("t2: ",t2)
print("t2.shape：: ",t2.shape) # t2.shape：:  (2, 3)

print("-----2-----")

t3 = np.array([[[1,2,3], [4,5,6]],[[7,8,9], [10,11,12]]])
print(t3)
print(t3.shape)

print("-----3-----")

t4 = np.arange(12)
print(t4)
print(t4.reshape(3,4)) # 修改数组的形状
print("再次t4:", t4) # t4 不发生变化

print("-----4-----")

t5 = np.arange(24).reshape((2,3,4))
print("t5：", t5)
print("t5.reshape(4, 6)：", t5.reshape(4, 6))
# t6 = t5.reshape((t5.shape[0] * t5.shape[1],)) # 可能出错
# print(t6)
print("t5.reshape(24,1)= ", t5.reshape(24,1))
print("再次t5=", t5) # t5 不发生变化

print("-----5-----")

print("t5.reshape(4, 6)=", t5.reshape(4, 6))
print(t5+ 2) # 每个数加2
print(t5/0)

print("-----6-----")

t6 = np.arange(100, 124).reshape((4,6))
print("t6=", t6)
print("相加t6=", t5.reshape(4, 6) + t6)
t7 = np.arange(0,6)
print("t7=", t7)
print("相减t7=", t5.reshape(4, 6)-t7) # t5.reshape(4, 6)每一项减去T7

print("-----7-----")

t8 = np.arange(4).reshape((4,1))
print("t8=",t8)
'''
t8= [[0]
 [1]
 [2]
 [3]]
'''
print(t5.reshape(4, 6)-t8)
'''结果
[[ 0  1  2  3  4  5]
 [ 5  6  7  8  9 10]
 [10 11 12 13 14 15]
 [15 16 17 18 19 20]]
'''

print("-----8-----")


t9 = np.array(10)
print("t9=", t9)
print(t5-t9) #  所有项减去t9